package logic.xmlLoader 
{
	import common.manager.Resource;
	
	import flash.geom.Rectangle;

	public class SkinRefXML
	{
		private var m_data : Object; 
		
		private var m_imgage : Object;
		private var m_simpleBtn : Object;
		private var m_UIFrame : Object;
		private var m_toggleBtn : Object;
		
		public function SkinRefXML()
		{
		}
		
		public function get data() : Object
		{
			return m_data;
		}
		
		public function get imageData() : Object
		{
			return m_imgage;
		}
		
		public function get simpleBtn() : Object
		{
			return m_simpleBtn;
		}
		
		public function get toggleBtn() : Object
		{
			return m_toggleBtn;
		}
		
		public function get UIFrame() : Object
		{
			return m_UIFrame;
		}
		
		public function prase() : void
		{
			m_data = new Object;
			m_imgage = new Object;
			m_simpleBtn = new Object;
			m_UIFrame = new Object;
			m_toggleBtn = new Object;
			
			var totalXML : XML = Resource.getXML("SkinRef");
			
			for each(var item : XML in totalXML.elements())
			{
				var itemInfo : Object = new Object;
				
				itemInfo["id"] = item.@id.toString();
				itemInfo["skin"] = item.@skin.toString();
				itemInfo["sort"] = int(item.@sort);
				
				m_data[item.@id] = itemInfo;
				
				if(item.name().localName == "Image")
				{
					m_imgage[item.@id] = itemInfo;
				}
				else if(item.name().localName == "SimpleBtn")
				{
					m_simpleBtn[item.@id] = itemInfo;
				}
				else if(item.name().localName == "ToggleButton")
				{
					m_toggleBtn[item.@id] = itemInfo;
				}
				else if(item.name().localName == "UIFrame")
				{
					var recPointStr : String = item.@scale9Grid.toString();
					var recpointLst : Array = recPointStr.split(/,/);
					
					var rec : Rectangle = new Rectangle(recpointLst[0],recpointLst[1],recpointLst[2],recpointLst[3]);
					
					item.@scale9Grid = rec;
					
					m_UIFrame[item.@id] = itemInfo;
				}
			}
		}
	}
}